package fw.communication.coap.activator;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

import fw.communication.api.ICommunicationLayer;
import fw.communication.coap.CoapCommunicationLayer;

/**
 * Activator - entry point for bundle
 * 
 * @author Andrei Penchev
 */
public class Activator implements BundleActivator{

	private ServiceRegistration servideRef;
	
	/**
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext bc) throws Exception {
		CoapCommunicationLayer service = new CoapCommunicationLayer();
		servideRef = bc.registerService(ICommunicationLayer.class.getName(), service, null);
	}

	/**
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext bc) throws Exception {
		if(servideRef != null) {
			servideRef.unregister();
		}
	}

}
